#pragma once
#include <iostream>
#include <memory>

// 抽象产品：按钮
class IButton
{
public:
    virtual void Paint() = 0;
    virtual ~IButton() = default;
};

// 抽象产品：文本框
class ITextBox
{
public:
    virtual void Paint() = 0;
    virtual ~ITextBox() = default;
};

// Windows风格按钮
class WindowsButton : public IButton 
{
public:
    void Paint() override 
    {
        std::cout << "绘制Windows风格按钮" << std::endl;
    }
};

// Windows风格文本框
class WindowsTextBox : public ITextBox 
{
public:
    void Paint() override 
    {
        std::cout << "绘制Windows风格文本框" << std::endl;
    }
};

// Mac风格按钮
class MacButton : public IButton 
{
public:
    void Paint() override 
    {
        std::cout << "绘制Mac风格按钮" << std::endl;
    }
};

// Mac风格文本框
class MacTextBox : public ITextBox
{
public:
    void Paint() override
    {
        std::cout << "绘制Mac风格文本框" << std::endl;
    }
};

// 抽象工厂
class IGUIFactory
{
public:
    virtual std::unique_ptr<IButton> CreateButton() = 0;
    virtual std::unique_ptr<ITextBox> CreateTextBox() = 0;
    virtual ~IGUIFactory() = default;
};

// Windows工厂
class WindowsFactory : public IGUIFactory 
{
public:
    std::unique_ptr<IButton> CreateButton() override 
    {
        return std::make_unique<WindowsButton>();
    }
    std::unique_ptr<ITextBox> CreateTextBox() override
    {
        return std::make_unique<WindowsTextBox>();
    }
};

// Mac工厂
class MacFactory : public IGUIFactory
{
public:
    std::unique_ptr<IButton> CreateButton() override 
    {
        return std::make_unique<MacButton>();
    }
    std::unique_ptr<ITextBox> CreateTextBox() override 
    {
        return std::make_unique<MacTextBox>();
    }
};